package com.suxin.chain.process;

import com.suxin.chain.Interceptor.Interceptor;
import com.suxin.chain.call.ContractCall;
import com.suxin.chain.domain.ContractRequest;
import com.suxin.chain.domain.ContractResponse;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: tang
 * @Description: 合同签章process
 * @Date 2024/6/20 10:11
 */
@Component
public class ContractSignProcessor<T extends ContractRequest> implements Processor<T,ContractResponse>{

    @Resource(name = "contractSignCompactInitImpl")
    Interceptor<T, ContractResponse> contractSignCompactInitImpl;

    @Override
    public ContractResponse process(T t) {
        // 加入所有的责任链
        List<Interceptor<T, ContractResponse>> interceptors = new ArrayList<>();
        interceptors.add(contractSignCompactInitImpl);

        // call
        ContractCall<T> contractCall = new ContractCall<>(t, interceptors);
        return contractCall.exectue();
    }

}
